<!--
 * @Author: ChunLai
 * @Date: 2022-04-15 10:45:11
 * @LastEditTime: 2025-09-12 10:39:18
 * @Description: 签名操作弹窗
 * @FilePath: \02.bldinsure\src\views\sign\components\SignTipMask.vue
-->
<template>
  <div class="mask" v-if="showMask">
    <div class="_modal">
      <div class="_modal-header">
        <div class="flex-lr">
          <span class="lineh1">{{ signUserName }}签字</span>
          <MsImgIcon name="cross" size="16" @click.native="showMask = false" />
        </div>
        <div class="p_label">
          为了保证合规性，请确认是 <i>{{ signUserName }}</i> 进行的签字
        </div>
      </div>
      <div class="_modal-content">
        <div class="pic_sign"></div>
      </div>
      <div class="_modal-footer">
        <span>
          <span class="name_c ftw5">{{ signUserName }}</span> 在身边？
        </span>
        <span class="_model_btn" @click="signNow()">立即签字</span>
      </div>
      <div class="_modal-footer mt10">
        <span>
          <span class="name_c ftw5">{{ signUserName }}</span> 不在身边？
        </span>
        <span class="_model_btn" @click="copySignLink()">
          {{ isWxEnv ? "复制链接给Ta" : "分享给Ta" }}</span
        >
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { wechatInitShareConfig, isWxChat } from "@/utils/wxJsSdk";
import { appShare } from "@/utils";
import { filterFieldValue, formatUrlSearch } from "@/methods/format.js";
export default {
  name: "SignTipMask",
  data() {
    return {
      isWxEnv: false,
      showMask: false,
      signStatus: false,
      uindex: 0,
      // userType:{},
    };
  },
  components: {},
  computed: {
    ...mapGetters({
      shareInfo: "home/shareInfo",
      productName: "varietyInfo/productName",
      apiBbrMult: "insert/apiBbrMult",
      userObj: "filesign/userObj",
      userType: "filesign/userType",
    }),
  },
  created() {
    this.isWxEnv = isWxChat();
  },
  mounted() {},
  beforeDestroy() {
    let that = this;
    document.body.removeEventListener("touchmove", that.cancelEvent, {
      passive: false,
    });
    document.body.classList.remove("van-overflow-hidden");
  },
  methods: {
    initModule(utype, user, status = false) {
      let msg = user,
        uname = "";
      uname = `${user.name}`;
      if (utype == "2") {
        const uidx = this.apiBbrMult.findIndex(
          (ele) => ele.idNum == user.idNum
        );
        if (uidx > -1) {
          this.uindex = uidx;
        }
        // console.log("未成年",this.$GlobalFuns.isMinorBaby(user))
        if (
          this.$GlobalFuns.isMinorBaby(user) &&
          user.guardianIdNo &&
          user.guardianName
        ) {
          msg = {
            name: user.guardianName,
            idNum: user.guardianIdNo,
          };
          uname = user.guardianName;
        }
      }
      this.signUserName = `${uname}`;
      this.signStatus = status;
      this.$store.commit("filesign/SET_SIGN_OBJ", msg);
      this.$store.commit("filesign/SET_STATE_CONFIG", {
        signName: `${uname}`,
        userType: `${utype}`,
      });
      this.showMask = true;
    },
    signNow() {
      this.showMask = false;
      let url = `/newsign`;
      if (this.signStatus) {
        url = `/newsign?status=1`;
      }
      this.$router.push(`${url}`);
    },
    copySignLink() {
      const nickName = this.userObj.name
          ? ` ${this.userObj.name} 先生/女士`
          : "客户",
        domainVal = window.location.origin + window.location.pathname;
      let uqrys = formatUrlSearch();
      if (uqrys.indexOf("ptype") != -1) {
        uqrys = filterFieldValue(uqrys, "ptype");
      }
      // console.log(`${domainVal}${uqrys}`);
      let baseLink = `${domainVal}${uqrys}&utype=${this.userType}&uindex=${
        this.uindex
      }&share=1&status=${
        this.signStatus ? "1" : "0"
      }&skind=qianming&ptype=newsign`;
      if (baseLink.indexOf("orderNum") == -1) {
        baseLink += `&orderNum=${this.orderNum}`;
      }
      if (this.isWxEnv) {
        wechatInitShareConfig(
          `${baseLink}`,
          `尊敬的${nickName}`,
          `邀请您进行${this.productName}产品投保签名`
        );
      } else {
        let shareData = {
          icon: `${this.shareInfo.icon}`,
          url: `${baseLink}`,
          title: `尊敬的${nickName}`,
          desc: `邀请您进行${this.productName}产品投保签名`,
        };
        appShare(shareData);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;

  ._modal {
    width: 90%;
    border-radius: 8px;
    padding: 15px 24px;
    overflow: hidden;
    background: linear-gradient(0deg, #ffeaea 0%, #ffffff 100%);

    ._modal-content {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 30px;
    }

    ._modal-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      height: 60px;
      font-weight: bold;
      padding: 0 12px;
      font-size: 15px;
      border-radius: 15px;
      background-color: #ffffff;

      ._model_btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 46%;
        height: 35px;
        font-size: 15px;
        border-radius: 35px;
        color: #ffffff;
        font-weight: 500;
        background: linear-gradient(270deg, #cb1800 0%, #ff462c 100%);
      }

      .name_c {
        color: rgba(255, 141, 26, 1);
      }
    }
  }
}

.lineh1 {
  font-size: 18px;
  font-weight: bold;
  color: #1b1b1b;
}

.p_label {
  font-size: 12px;
  color: #1b1b1b;
  margin-top: 4px;

  i {
    color: #ff8d1a;
    font-size: 15px;
    font-style: normal;
    font-weight: 600;
  }
}
</style>
